<template>
  <div class="header-container">
    <div class="l-content">
      <el-button icon="el-icon-menu" style="margin-left:20px;" @click="handleMenu"></el-button>
      <span class="firstPage">首页</span>
    </div>
    <div class="r-content">
      <el-dropdown @command="handleCommand">
      <span class="el-dropdown-link">
        <img class="user_img" src="@/assets/images/17.png"/>
      </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="a">个人信息</el-dropdown-item>
          <el-dropdown-item command="b">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import {changeRepeat} from "autoprefixer/lib/hacks/grid-shorthand";

export default {
  name: 'header',
  methods: {changeRepeat,
    handleMenu(){
      //对菜单做缩放操作
      this.$store.commit('collapseChange')
    },handleCommand(command){
      if('b' === command){
        this.$confirm('是否确认退出登录?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          //表示处理的是注销操作
          sessionStorage.clear()  //清空存储的token信息
          //跳转到登录页面
          this.$router.push("/login")
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
      }
    }
  },
  date() {
    return {}
  },
}

</script>

<style lang="less" scoped>
.header-container {
  height: 70px;
  background-color: #242f42;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .firstPage {
    color: white;
    font-size: 18px;
    margin-left: 18px;
    cursor: pointer;
  }
  .r-content{
    padding-right: 20px;
    .user_img{
      width: 40px;
      height:40px;
      border-radius: 50%;
    }
  }
}
</style>
